<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link href="//cdn.staticfile.org/layui/2.9.2/css/layui.css" rel="stylesheet">
    <script src="//cdn.staticfile.org/layui/2.9.2/layui.js"></script>
</head>
<body>
<form class="layui-form" th:action="@{/login}" method="post" style="max-width: 400px; margin: 0 auto;">
    <div th:if="${param.error}">
        <div class="alert alert-danger">
            无效的用户名或密码！
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">账号:</label>
        <div class="layui-input-block">
            <input type="email" name="email" class="layui-input" lay-verify="required" placeholder="请输入Email" lay-affix="clear"
                   autocomplete="off"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码:</label>
        <div class="layui-input-block">
            <input type="password" name="password" lay-verify="required" lay-affix="eye" placeholder="请输入" class="layui-input"/>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit lay-filter="penguin-login">登录</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script>
    layui.use(function () {
        var form = layui.form;
        var layer = layui.layer;
        form.on('submit(penguin-login)', function (data) {
            var field = data.field; // 获取表单字段值
            // 显示填写结果，仅作演示用
            layer.alert(JSON.stringify(field), {
                title: '当前填写的字段值'
            });
            // 此处可执行 Ajax 等操作
            return true; // 阻止默认 form 跳转
        });
    });
</script>

</body>
</html>